<?php
	error_reporting(0);
	$errorMsg = $_GET['errorMsg'];
	
	$userID = $_SESSION['userId'];
	
	$con = mysql_connect("localhost", "group5", "group5");
    if(!$con)
    {
		echo "Connection failed!";
        exit;
    }
	
	mysql_select_db("group5");?>
	
	
	<script type="text/javascript">
	function addRoom()
	{
		window.location.href = 'addRoom.php';
	}
	
	function addWorkshop()
	{
		window.location.href = 'addWorkshop.php';
	}
	</script>
	<p> Please enter the data below:</p>
	
	<form name='create' method='post' action='createSession.php'>
	Meeting Date:      <input type='text' id='date-drop' name='meetdate' min='<?php echo date("Y-m-d");?>'><br>
	Meeting Time: <input type='text' id="time-drop" name='meetingtime'><br>
	Building:     <select id='building' name='building'>
				<option value=''>Select a building</option>
				<?php
				$buildingQuery = 'select * from BUILDING';
				$buildingResult = mysql_query($buildingQuery, $con);
				
				while ($buildingRow = mysql_fetch_row($buildingResult))
				{
					$buildingId = $buildingRow[0];
					$buildingName = $buildingRow[1];
					$buildingNum = $buildingRow[2];
					echo "<option value='$buildingId'>$buildingNum - $buildingName</option>";
				}
				?></select><br>
	Room: <select id='room' name='room'>
		  <option value=''>Select a room</option>
		  <?php
				$roomQuery = 'select * from ROOM';
				$roomResult = mysql_query($roomQuery, $con);
				
				while ($roomRow = mysql_fetch_row($roomResult))
				{
					$roomId = $roomRow[0];
					$roomCap = $roomRow[1];
					$roomNum = $roomRow[2];
					echo "<option value='$roomId'>$roomNum - Capacity: $roomCap </option>";
				}
				?></select><br>
	Workshop:    <select name='category'>
	<option value=''>Select a Workshop</option>
	<?php $table = mysql_query("select * from WORKSHOP", $con);

	while($getRow = mysql_fetch_row($table))
	{
		$workshopId = $getRow[0];
		$title = $getRow[1];
		$descrip = $getRow[2];
		
		 ?><option value ='<?php echo $workshopId;?>'><?php echo $title;?></option><?php
	}?>
	
	</select>
	<input type='hidden' name='capacity' id='capacity' value='<?php echo $roomCap;?>'>
	<br>*Note: We will create a session ID for you. It will be visible on your View/Edit My Sessions page.
	<input class="btn" type='submit' value='Create New Session'></form>

<p id='regError'><?php echo $errorMsg; ?></p>
